\begin{algorithm}
\caption{DFSLabel($G[P](V,E), P_1 \cup \cdots \cup P_k$}
\label{alg:DFSLabel}
\begin{algorithmic}[1]
\REQUIRE{$P_1 \cup \cdots \cup P_k$ is the path-decomposition of $G$}
\REQUIRE{$G[P]$ is represented as linked lists: $\forall v \in V: linkedlist(v)$ records all the immediate neighbors of $v$. Let $v \in P_i$. If $v$ is not the last vertex in path $P_i$, the first vertex in the linked list is the next vertex of $v$ in the path}
\REQUIRE{$P_i \preceq P_j \Longleftrightarrow i \leq j$}
\STATE $N \leftarrow |V|$
\FOR{$i=1$ to $k$}
    \STATE $v \leftarrow P_i[1]$ \COMMENT{$P_i[1]$ is the first vertex in the path}
    \IF{$v$ is not visited} 
         \STATE DFS($v$)\\
    \ENDIF
\ENDFOR
\end{algorithmic}
\begin{algorithmic}[1]
\PROCEDURE{DFS($v$)}
\STATE $visited(v) \leftarrow TRUE$
\FORALL{$v^\prime \in linkedlist(v)$}
     \IF{$v^\prime$ is not visited}
         \STATE DFS($v^\prime$)
     \ENDIF
\ENDFOR
\STATE $X(v) \leftarrow N$ \COMMENT{Label vertex $v$ with $N$}
\STATE $N \leftarrow N-1$
\end{algorithmic}
\end{algorithm}